#include "Socket.hpp"
using namespace SocketModule;

void Usage(const std::string &name)
{
    std::cout << "usage: " << name << " + ip" << " + port" << std::endl;
}

int main(int argc, char* args[])
{
    if (argc != 3)
    {
        Usage(args[0]);
        exit(USAGE_ERROR);
    }

    in_port_t port = std::stoi(args[2]);
    TCPClientSocket cli_socket(args[1], port);

    std::string send_msg, recv_msg;
    InetAddr server = cli_socket.addr();
    while(true)
    {
        std::cout << "Send to Server# ";
        std::getline(std::cin, send_msg);
        cli_socket.Send(send_msg);
        int size = cli_socket.Receive(recv_msg);
        std::cout << "Recive from Client[" << server.Info() << "]# " << recv_msg << std::endl;
    }

    return 0;
}